
package com.rt.schedulenew.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rt.schedulebase.dto.ExamsDto;
import com.rt.schedulebase.entity.Exams;
import com.rt.schedulebase.mapper.ExamsMapper;
import com.rt.schedulenew.api.IExamsService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ExamsServiceImpl extends ServiceImpl<ExamsMapper, Exams> implements IExamsService {
    @Override
    public List<Exams> selectList(ExamsDto dto) {
        Map<String, Object> map = new HashMap<>();
        map.put("APPLY_NO", dto.getApplyNo());
        map.put("EXAM_NO", dto.getExamNo());
        QueryWrapper<Exams> qw = new QueryWrapper<>();
        qw.allEq(map, false);
        if (dto.getApplyNos() != null && !dto.getApplyNos().isEmpty()) {
            qw.in("APPLY_NO", dto.getApplyNos());
        }
        qw.ne("EXAM_STATUS", "00");
        return baseMapper.selectList(qw);
    }

    @Override
    public boolean insertSelective( Exams exams) {
        return this.retBool(this.baseMapper.insert(exams));
    }

    @Override
    public boolean deleteByPrimaryKey( String key) {
        return this.retBool(this.baseMapper.deleteById(key));
    }

    @Override
    public boolean updateByPrimaryKeySelective( Exams exams) {
        return this.retBool(this.baseMapper.updateById(exams));
    }

    @Override
    public Exams selectByPrimaryKey( String key) {
        return this.baseMapper.selectById(key);
    }

    @Override
    public List<Exams> getList( ExamsDto dto) {
         QueryWrapper<Exams> qw = new QueryWrapper<>();
         Map<String, Object> map = new HashMap<>();
        map.put("APPLY_NO", dto.getApplyNo());
        map.put("EXAM_NO", dto.getExamNo());
        qw.allEq(map, false);
         List<Exams> list = this.baseMapper.selectList(qw);
        return list;
    }

    @Override
    public List<Exams> getListAll() {
        return this.baseMapper.selectList(null);
    }

    @Override
    public boolean delete( Exams exams) {
         UpdateWrapper<Exams> uw = new UpdateWrapper<>();
         Map<String, Object> map = new HashMap<>();
        uw.allEq(map, false);
        return this.retBool(this.baseMapper.delete(uw));
    }

    @Override
    public boolean update( Exams exams) {
         UpdateWrapper<Exams> uw = new UpdateWrapper<>();
         Map<String, Object> map = new HashMap<>();
        map.put("APPLY_NO", exams.getApplyNo());
        map.put("EXAM_NO", exams.getExamNo());
        uw.allEq(map, false);
        return this.retBool(this.baseMapper.update(exams, uw));
    }

    @Override
    public Exams getInfo( ExamsDto dto) {
         QueryWrapper<Exams> qw = new QueryWrapper<>();
         Map<String, Object> map = new HashMap<>();
        map.put("APPLY_NO", dto.getApplyNo());
        map.put("EXAM_NO", dto.getExamNo());
        qw.allEq(map, false);
        return this.baseMapper.selectOne(qw);
    }
}
